//
//  NSString+Size.m
//  Nectar
//
//  Created by famer on 2023/11/11.
//  Copyright © 2023 asance. All rights reserved.
//

#import "NSString+Size.h"

@implementation NSString (Size)
- (CGSize)textBoundingSizeWithMaxSize:(CGSize)maxSize font:(UIFont *)font{
    if(0==self.length) return CGSizeZero;
    
    CGRect rect = [self boundingRectWithSize:maxSize
                                          options:(NSStringDrawingOptions)(NSStringDrawingUsesFontLeading | NSStringDrawingTruncatesLastVisibleLine | NSStringDrawingUsesLineFragmentOrigin)
                                       attributes:@{NSFontAttributeName:font}
                                          context:nil];
    
    CGSize newrect = CGSizeMake(rect.size.width+5, rect.size.height);
    
    return newrect;
}
@end
